package com.xbongbong.pro.statistic.pojo.vo;

import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.toolbox.wrap.BaseVO;
import com.xbongbong.pro.domain.entity.ChartCategoryEntity;
import com.xbongbong.pro.domain.entity.ChartEntity;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 图表分类初始化VO
 *
 * @author 徐俊杰
 * @version v1.0
 * @date 2019/1/23 14:58
 * @since v1.0
 */
@Setter
@Getter
//@ToString
public class ChartCategoryInitVO extends BaseVO {
    private static final long serialVersionUID = -1676258280958667704L;
    /**
     * flag = 1表示不需要初始化，flag = 2表示添加新的图表分类成功
     */
    private Integer flag;
    /**
     * 当前公司的图表分类
     */
    private List<ChartCategoryEntity> categoryList;
    /**
     * 当前公司的图表
     */
    private List<ChartEntity> chartList;

    /**
     * key：分类id
     * value：分类实体
     */
    private Map<Long, ChartCategoryEntity> categoryMap;
    /**
     * TODO 此处的key暂时还用Long，下游库内的IndexBoardChartSavePojo只有id和sort，没有statisticsType。后续要用 statisticsType_图表id形式标识key
     * key：系统图表id
     * value：系统图表实体
     */
    private Map<Long, ChartEntity> systemChartMap;
    /**
     * key：自定义图表id
     * value：图表实体
     */
    private Map<Long, ChartEntity> customChartMap;

    /**
     * 获取分类map，防空
     * key：分类id
     * value：分类实体
     * @return java.util.Map<java.lang.String,com.xbongbong.pro.domain.entity.ChartEntity>
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public Map<Long, ChartCategoryEntity> getCategoryMap(){
        if (Objects.isNull(categoryMap)) {
            this.categoryMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        }
        return categoryMap;
    }
    /**
     * 获取图表map，防空
     * key：statisticsType_图表id
     * value：图表实体
     * @return java.util.Map<java.lang.String,com.xbongbong.pro.domain.entity.ChartEntity>
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public Map<Long, ChartEntity> getSystemChartMap(){
        if (Objects.isNull(systemChartMap)) {
            this.systemChartMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        }
        return systemChartMap;
    }
    public Map<Long, ChartEntity> getCustomChartMap(){
        if (Objects.isNull(customChartMap)) {
            this.customChartMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        }
        return customChartMap;
    }
}
